﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _05_AngryBits
{
    class Program
    {
        static void Main(string[] args)
        {
            ushort[,] matrix = new ushort[8, 16];
            ushort currentNum;
            int totalScore = 0;
            int bit;
            int currentRes;
            int shift, mask ;
                //Fill matrix
            for (ushort i = 0; i < 8; i++)
            {
                currentNum = ushort.Parse(Console.ReadLine());
                for (ushort j = 0; j < 16; j++)
                {
                    shift = 15 - j;
                    mask = 1 << shift;
                    currentRes = currentNum & mask;
                    bit = currentRes >> shift;
                    matrix[i, j] =Convert.ToUInt16(bit);
                }
            }
                 //Print matrix
            //printMatrix(matrix);
                 //Attack the pigs
            int length = 0;
            int pigs = 0;
            int columnIndex,rowIndex;
            int adder;
            for (int q = 7; q >=0; q--)
            {
                for (int p = 0; p <8; p++)
                {
                    if (matrix[p,q]==1)
                    {
                        if (p==0)
                        {
                            adder = 1;//bird goes directly down
                        }
                        else
                        {
                            adder = -1;//otherwise bird goes firstly up
                        }
                      
                        length = 1;
                        pigs = 1;
                        columnIndex = q + 1;
                        rowIndex = p+adder;
                        while (columnIndex<=15&&rowIndex>=0&&rowIndex<8)
                        {                   
                            if (matrix[rowIndex,columnIndex]==0)
                            {
                                matrix[rowIndex, columnIndex] = 1;
                                matrix[rowIndex - adder, columnIndex - 1] = 0;
                            }
                            else if (columnIndex>7)
                            {
                                matrix[rowIndex, columnIndex] = 0;
                                matrix[rowIndex - adder, columnIndex - 1] = 0;
                                //destroy pigs
                                pigs = destroyPigs(matrix,rowIndex, columnIndex);
                                totalScore += length * pigs;
                                columnIndex++;
                                rowIndex += adder;
                                break;
                            }
                            if (rowIndex==0)
                            {
                                //go down
                                adder = +1;
                            }
                            columnIndex++;
                            rowIndex += adder;
                            length++;
                        }
                        matrix[rowIndex - adder, columnIndex - 1] = 0;
                       // Console.WriteLine( ); printMatrix(matrix);
                        break;//One bird per column
                    }
                }
            }
                bool win = true;
                for (int l = 0; l < 8; l++)
                {
                    for (int m = 0; m < 16; m++)
                    {
                        if (matrix[l, m] == 1)
                        {
                            win = false;
                            break;
                        }
                    }
                    if (win == false)
                    {
                        break;
                    }
                }
               // Console.WriteLine();printMatrix(matrix);            
                string resultWin;
                if (win==true)
	            {
		            resultWin="Yes";
	            }
                else
                {
                    resultWin="No";
                }
                Console.WriteLine("{0} {1}",totalScore,resultWin);       
        }

        private static int destroyPigs(ushort[,] matrix, int rowIndex, int columnIndex)
        {
            int cnt = 1;
            if (rowIndex>0&&matrix[rowIndex-1,columnIndex-1]==1)
            {
                cnt++;
                matrix[rowIndex - 1, columnIndex - 1] = 0;
            }
            if (rowIndex>0&&matrix[rowIndex-1,columnIndex]==1)
            {
                cnt++;
                matrix[rowIndex - 1, columnIndex] = 0;
            }
            if (rowIndex>0 && columnIndex<15 && matrix[rowIndex-1,columnIndex+1]==1)
            {
                cnt++;
                matrix[rowIndex - 1, columnIndex + 1] = 0;
            }
            if (matrix[rowIndex,columnIndex-1]==1)
            {
                cnt++;
                matrix[rowIndex, columnIndex - 1] = 0;
            }
            if (columnIndex<15 && matrix[rowIndex,columnIndex+1]==1)
            {
                cnt++;
                matrix[rowIndex, columnIndex + 1] = 0;
            }
            if (rowIndex<7 && matrix[rowIndex+1,columnIndex-1]==1)
            {
                cnt++;
                matrix[rowIndex + 1, columnIndex - 1] = 0;
            }
            if (rowIndex<7 && matrix[rowIndex+1,columnIndex]==1)
            {
                cnt++;
                matrix[rowIndex + 1, columnIndex] = 0;
            }
            if (rowIndex<7 && columnIndex<15 && matrix[rowIndex+1,columnIndex+1]==1)
            {
                cnt++;
                matrix[rowIndex + 1, columnIndex + 1] = 0;
            }
            return cnt;
        }

        private static void printMatrix(ushort[,] matrix)
        {
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    Console.Write("{0,4}",matrix[i,j]);
                }
                Console.WriteLine();
            }
        }
    }
}
